package test1230pm;



public class Test03 {
    public static void main(String[] args) {
        // (3)设计一个公司类和员工类
        // 场景：员工张三在IBM公司工作、员工李四在HP公司工作
        // 要求：根据需求创建员工和公司对象、并能表示出员工和公司之间的关联关系、打印员工以及所在公司的信息
        // 创建公司对象

        Member member = new Member("张三");
        Company company = new Company("IBM");
        member.setCompany(company);

        System.out.println(member);
        System.out.println(member.getName());
        System.out.println(member.getCompany().getName());
    }

    public static class Company {

        String name;

        public Company() {
        }

        public Company(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        @Override
        public String toString() {
            return "Company{" +
                    "name='" + name + '\'' +
                    '}';
        }

    }

    public static class Member {

        String name;

        // 难点：思考
        Company company;

        public Member() {
        }

        public Member(String name) {
            this.name = name;
        }

        public Company getCompany() {
            return company;
        }

        public void setCompany(Company company) {
            this.company = company;
        }

        public String getName() {
            return name;
        }
    
        public void setName(String name) {
            this.name = name;
        }

        @Override
        public String toString() {
            return "Member{" +
                    "name='" + name + '\'' +
                    ", company=" + company +
                    '}';
        }
    }
}